﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace BSE.Windows.Test
{
    public partial class YishiForm : Form
    {
        public Yishi yishi = null;

        public YishiForm()
        {
            InitializeComponent();
        }

        private void YishiForm_Load(object sender, EventArgs e)
        {
            if (yishi != null)
            {
                textBoxCode.Text = yishi.YishiCode;
                textBoxName.Text = yishi.YishiName;

                labelKeshi.Visible = true;
                comboBoxKeshi.Visible = true;

                List<Keshi> ks = AnesthesiaBLL.GetAllKeshi();
                comboBoxKeshi.DataSource = ks;
                comboBoxKeshi.DisplayMember = "KeshiName";
                comboBoxKeshi.ValueMember = "KeshiID";
                comboBoxKeshi.SelectedValue = yishi.YishiKeshiID;
            }
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            if (textBoxCode.Text.Length == 0)
            {
                MessageBox.Show("医师编码不能为空", "医院", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxCode.Focus();
            }

            if (textBoxName.Text.Length == 0)
            {
                MessageBox.Show("医师名称不能为空", "医院", MessageBoxButtons.OK, MessageBoxIcon.Error);
                textBoxName.Focus();
            }

            if (yishi == null)
                yishi = new Yishi();
            else
                yishi.YishiKeshiID = comboBoxKeshi.SelectedValue.ToString();

            yishi.YishiCode = textBoxCode.Text;
            yishi.YishiName = textBoxName.Text;
        }
    }
}
